var i;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var BundleConfig = require("AA_BundleConfig");
var ADManager = require("AA_ADManager");
var EventManager = require("AA_EventManager");
var TipsManager = require("AA_TipsManager");
var UIManager = require("AA_UIManager");
var UIView = require("AA_UIView");
var TimeUtils = require("AA_TimeUtils");
var UIRotate = require("AA_UIRotate");
var EvenType = require("AA_EvenType");
var PlayerDataManager = require("AA_PlayerDataManager");
var Excel = require("AA_Excel");
var GameDataManager = require("AA_GameDataManager");
var GameGlobalVariable = require("AA_GameGlobalVariable");
var UIConfig_Game = require("AA_UIConfig_Game");
var Const_Hall = require("AA_Const_Hall");
var HallGlobalVariable = require("AA_HallGlobalVariable");
var UIConfig_Home = require("AA_UIConfig_Home");
var UI_BoxAward = require("AA_UI_BoxAward");
var _decorator = cc._decorator;
var _ccclass = _decorator.ccclass;
var _property = _decorator.property;

var _def_UI_WuJinTiaoZhan = function (e) {
  function _creator() {
    var t = null !== e && e.apply(this, arguments) || this;
    t.wujintime = null;
    t.wujinfenshu = null;
    t.wujincount = null;
    t.shaodangBt = null;
    t.awardBoxs = null;
    t.awardNode = null;
    t.startBt = null;
    t.saodangLb = null;
    t.kaishiLb = null;
    t.tagfen = [1500, 3e3, 4500, 6e3];
    return t;
  }
  __extends(_creator, e);
  _creator.prototype.onEnable = function () {
    EventManager.EventMgr.addEventListener(EvenType.EVENT_TYPE.GAME_TIAOZHAN_COUNT, this.initWuJinUi, this);
    EventManager.EventMgr.addEventListener(EvenType.EVENT_TYPE.Game_TiaoZhan_JiFen, this.initWuJinUi, this);
    EventManager.EventMgr.addEventListener(EvenType.EVENT_TYPE.Game_TIAOZHAN_PASS, this.initWuJinUi, this);
    this.initWuJinUi();
  };
  _creator.prototype.onDisable = function () {
    EventManager.EventMgr.rmEventListener(EvenType.EVENT_TYPE.Game_TiaoZhan_JiFen, this.initWuJinUi, this);
    EventManager.EventMgr.rmEventListener(EvenType.EVENT_TYPE.GAME_TIAOZHAN_COUNT, this.initWuJinUi, this);
    EventManager.EventMgr.rmEventListener(EvenType.EVENT_TYPE.Game_TIAOZHAN_PASS, this.initWuJinUi, this);
  };
  _creator.prototype._show = function (e) {
    var t = [];
    for (var o = 1; o < arguments.length; o++) {
      t[o - 1] = arguments[o];
    }
  };
  _creator.prototype.initWuJinUi = function () {
    var e = PlayerDataManager.PlayerDataMgr.getWuJinCount();
    this.wujincount.string = "今日剩余" + e + "次";
    this.wujinfenshu.string = "今日累计" + GameDataManager.GameDataMgr.getTiaoZhanFen(1);
    if (1 == GameDataManager.GameDataMgr.getNowLevelPassState(1, 1)) {
      this.shaodangBt.active = true;
    } else {
      this.shaodangBt.active = false;
    }
    this.initAwardBox();
    this.saodangLb.string = "×" + GameGlobalVariable.GameGlobalVariable.wujinsaodangcount;
    this.kaishiLb.string = "×" + GameGlobalVariable.GameGlobalVariable.wujintilicount;
  };
  _creator.prototype.initAwardBox = function () {
    var e = this.awardBoxs.children;
    for (var t = 0; t < e.length; t++) {
      var o = e[t];
      var n = this.tagfen[t];
      o.children[1].getComponent(cc.Label).string = "累计" + n + "分";
      if (GameDataManager.GameDataMgr.getTiaoZhanFen(1) >= n) {
        if (GameDataManager.GameDataMgr.getTiaoZhanAwardJilu(1, t + 1)) {
          o.children[0].getChildByName("unlockimg").active = true;
          o.children[0].getChildByName("lockimg").active = false;
          o.children[0].getChildByName("redpoint").active = false;
          o.children[0].getComponent(UIRotate.default).stopRotate();
        } else {
          o.children[0].getChildByName("unlockimg").active = false;
          o.children[0].getChildByName("lockimg").active = true;
          o.children[0].getChildByName("redpoint").active = true;
          o.children[0].getComponent(UIRotate.default).startRotate();
        }
      } else {
        o.children[0].getChildByName("unlockimg").active = false;
        o.children[0].getChildByName("lockimg").active = true;
        o.children[0].getChildByName("redpoint").active = false;
        o.children[0].getComponent(UIRotate.default).stopRotate();
      }
    }
  };
  _creator.prototype.onSaoDang = function () {
    if (PlayerDataManager.PlayerDataMgr.dressUpArray.every(function (e) {
      return 0 != e;
    })) {
      if (PlayerDataManager.PlayerDataMgr.globalData.power >= GameGlobalVariable.GameGlobalVariable.wujinsaodangcount) {
        if (PlayerDataManager.PlayerDataMgr.getWuJinCount() > 0) {
          ADManager.ADMgr.showRewardedVideo("视频扫荡", function () {
            GameGlobalVariable.GameGlobalVariable.nowlevel = -1;
            GameGlobalVariable.GameGlobalVariable.teshulevel = 1;
            PlayerDataManager.PlayerDataMgr.SubPower(GameGlobalVariable.GameGlobalVariable.wujinsaodangcount);
            PlayerDataManager.PlayerDataMgr.subWuJinCount(1);
            UIManager.default.open(BundleConfig.BundleNames.Game, UIConfig_Game.UIView_Game.UI_GameOver, {
              type: 2,
              back: function () {}
            });
          });
        } else {
          TipsManager.TipMgr.showToast("今日挑战次数用尽");
        }
      } else {
        TipsManager.TipMgr.showToast("体力不足");
      }
    } else {
      TipsManager.TipMgr.showToast("背包中有空位未上阵水果");
    }
  };
  _creator.prototype.showTip = function () {
    UIManager.default.open(BundleConfig.BundleNames.Home, UIConfig_Home.UIView_Home.UI_ShuoMing);
  };
  _creator.prototype.onStartGame = function () {
    if (PlayerDataManager.PlayerDataMgr.globalData.power >= GameGlobalVariable.GameGlobalVariable.wujintilicount) {
      if (PlayerDataManager.PlayerDataMgr.getWuJinCount() > 0) {
        PlayerDataManager.PlayerDataMgr.SubPower(GameGlobalVariable.GameGlobalVariable.wujintilicount);
        EventManager.EventMgr.dispatchEvent(EvenType.EVENT_TYPE.GAME_TIAOZHAN_VIEW);
        this._close();
      } else {
        TipsManager.TipMgr.showToast("今日挑战次数用尽");
      }
    } else {
      TipsManager.TipMgr.showToast("体力不足");
    }
  };
  _creator.prototype.onAwardBoxClick = function (e, t) {
    var o = this.tagfen[Number(t) - 1];
    var n = GameDataManager.GameDataMgr.getTiaoZhanFen(1);
    var i = Excel.Excel.shuiguoguanqia(5);
    if (n < o) {
      var a = e.getCurrentTarget();
      this.awardNode.getComponent(UI_BoxAward.default).showAward(a, i, t, 2);
    } else {
      if (GameDataManager.GameDataMgr.getTiaoZhanAwardJilu(1, Number(t))) {
        TipsManager.TipMgr.showToast("已领取");
      } else {
        TipsManager.TipMgr.showToast("恭喜获得奖励");
        switch (t) {
          case "1":
            this.getAwardData(i.tiaozhanbox1);
            break;
          case "2":
            this.getAwardData(i.tiaozhanbox2);
            break;
          case "3":
            this.getAwardData(i.tiaozhanbox3);
            break;
          case "4":
            this.getAwardData(i.tiaozhanbox4);
        }
        GameDataManager.GameDataMgr.unTiaoZhanAwardJiLu(1, Number(t));
      }
      this.initAwardBox();
    }
  };
  _creator.prototype.getAwardData = function (e) {
    var t = new Const_Hall.GetItemsData();
    t.ids = [];
    t.counts = [];
    for (var o = 0; o < e.length; o++) {
      var n = e[o];
      switch (n[0]) {
        case 1:
          t.ids.push(HallGlobalVariable.default.goldId);
          t.counts.push(n[1]);
          break;
        case 2:
          t.ids.push(HallGlobalVariable.default.diamondId);
          t.counts.push(n[1]);
          break;
        case 3:
          t.ids.push(HallGlobalVariable.default.powerId);
          t.counts.push(n[1]);
          break;
        case 5:
          var i = null;
          1 == n[1] && (i = HallGlobalVariable.default.GetSuiPian([n[2], 0, 0]));
          2 == n[1] && (i = HallGlobalVariable.default.GetSuiPian([0, n[2], 0]));
          3 == n[1] && (i = HallGlobalVariable.default.GetSuiPian([0, 0, n[2]]));
          i.forEach(function (e, o) {
            t.ids.push(o);
            t.counts.push(e);
          });
      }
    }
    t.clickCallBack = function () {
      for (var e = 0; e < t.ids.length; e++) {
        var o = t.ids[e];
        var n = t.counts[e];
        switch (o) {
          case HallGlobalVariable.default.goldId:
            EventManager.EventMgr.dispatchEvent(EvenType.EVENT_TYPE.Home_Add_Gold, 2, n);
            break;
          case HallGlobalVariable.default.diamondId:
            EventManager.EventMgr.dispatchEvent(EvenType.EVENT_TYPE.Home_Add_Gold, 3, n);
            break;
          case HallGlobalVariable.default.powerId:
            EventManager.EventMgr.dispatchEvent(EvenType.EVENT_TYPE.Home_Add_Gold, 1, n);
            break;
          default:
            TipsManager.TipMgr.showToast("恭喜获得水果碎片");
            PlayerDataManager.PlayerDataMgr.AddEquipFragments(o, n);
        }
      }
    };
    UIManager.default.open(BundleConfig.BundleNames.Home, UIConfig_Home.UIView_Home.UI_GetItems, t);
  };
  _creator.prototype.update = function () {
    this.wujintime.string = TimeUtils.default.secondsToHMS(TimeUtils.default.getTimeUntilMidnight() / 1e3) + "刷新";
  };
  _creator.prototype.onCloseView = function () {
    this._close();
  };
  __decorate([_property(cc.Label)], _creator.prototype, "wujintime", undefined);
  __decorate([_property(cc.Label)], _creator.prototype, "wujinfenshu", undefined);
  __decorate([_property(cc.Label)], _creator.prototype, "wujincount", undefined);
  __decorate([_property(cc.Node)], _creator.prototype, "shaodangBt", undefined);
  __decorate([_property(cc.Node)], _creator.prototype, "awardBoxs", undefined);
  __decorate([_property(cc.Node)], _creator.prototype, "awardNode", undefined);
  __decorate([_property(cc.Node)], _creator.prototype, "startBt", undefined);
  __decorate([_property(cc.Label)], _creator.prototype, "saodangLb", undefined);
  __decorate([_property(cc.Label)], _creator.prototype, "kaishiLb", undefined);
  return __decorate([_ccclass], _creator);
}(UIView.default);
exports.default = _def_UI_WuJinTiaoZhan;